﻿@model WorkTimePrj.Models.Item[]
@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>工单管理</title>
   
    <link href="@Url.Content("~/Content/css/Basic.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/usecss.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/mgmt.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.7.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
   
    <script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
    <style type="text/css">
        .mytd select { width: 300px; font-family: simsun; }
        .Link { font-size: 10pt; color: #696969; font-family: simsun; text-decoration: none; /*display:block;float:left;*/ margin-right: 15px; border-bottom: solid 1px #696969; }
        div.WP01 { margin: 10px 0 30px 10px; }
    </style>
</head>
<body>
    @using (Html.BeginForm(new { startTime = ViewBag.startTime, endTime = ViewBag.endTime }))
    { 
        <input id="HStartTime" name="HStartTime" type="hidden" value="@ViewBag.startTime"/>
        <input id="HEndTime" name="HEndTime" type="hidden" value="@ViewBag.endTime"/>
        <div id="layout" class="layout">
            <div style="margin: 20px;">
                <table width="100%">
                    <tr>
                        <td>
                            <button type="button" onclick="window.location.href='@Url.Action("Index", new { startTime = ViewBag.startTime.AddDays(-7), endTime = ViewBag.endTime.AddDays(-7) })'"
                            class="Button01" style="line-height: 24px; height: 24px; margin-top: 2px;">
                                <span style="margin: 0px; padding: 0px;">上一周</span>
                            </button>
                            <input type="text" class="input2" style="width: 205px;font-family:simsun;text-align:center;" value="@ViewBag.startTime.ToString("yyyy年MM月dd日")-@ViewBag.endTime.ToString("yyyy年MM月dd日")" />
                            @if (ViewBag.startTime.AddDays(7) < DateTime.Now)
                            { 
                                <button type="button" onclick="window.location.href='@Url.Action("Index", new { startTime = ViewBag.startTime.AddDays(7), endTime = ViewBag.endTime.AddDays(7) })'"
                            class="Button01" style="line-height: 24px; height: 24px; margin-top: 2px;">
                                    <span tag="translate" style="margin: 0px; padding: 0px;">下一周</span>
                                </button>
                            }
                            &nbsp;工作量总计<span id="SP01">@ViewBag.WorkHours</span> &nbsp; &nbsp; &nbsp;
                            @Html.ActionLink("申请请假外出", "AddVacOT_New", "Admin", null, new { @class = "Link", target = "_blank" })
                            @if (((String)ViewBag.roles).IndexOf("PM") != -1 || ((String)ViewBag.roles).IndexOf("ProjMgmt") != -1)
                            {
                                @Html.ActionLink("工时确认", "Index", "PM", null, new { @class = "Link", target = "_blank" })
                            }
                            @if (((String)ViewBag.roles).IndexOf("ProjMgmt") != -1)
                            {
                                @Html.ActionLink("用户工作量统计", "Index", "Admin", null, new { @class = "Link", target = "_blank" })
                            }
                            @if (((String)ViewBag.roles).IndexOf("ProjMgmt") != -1)
                            {
                                @Html.ActionLink("项目工作量统计", "List", "Admin", null, new { @class = "Link", target = "_blank" })
                            }
                            @if (((String)ViewBag.roles).IndexOf("ProjMgmt") != -1)
                            {                                                                                       
                                @Html.ActionLink("用户工时休假统计", "WorkVOT", "Admin", null, new { @class = "Link", target = "_blank" })
                            }
                        </td>
                        @if (ViewBag.startTime.AddDays(8) > DateTime.Now)
                        {
                            <td align="right">
                                <input id="Submit" class="Button01" style="line-height: 24px; height: 24px; margin-top: 2px;"
                                    type="submit" value="提交" />
                            </td>
                        }
                    </tr>
                </table>
            </div>
            <div class="form">
                <div class="settings" style="padding: 10px;">
                    <table class="list" id="tblList" cellspacing="0" border="1" style="width: 100%; border-collapse: collapse;
                        border-color: #d1d1d1;">
                        <tbody>
                            <tr class="listtitle tableline">
                                <th width="30%" tag="translate" style="font-size: 15px; font-weight: bold; color: #5ba633;">
                                    所属项目
                                </th>
                                <th width="10%" tag="translate" style="font-size: 15px; font-weight: bold; color: #5ba633;">
                                    工作时长
                                </th>
                                <th tag="translate" style="font-size: 15px; font-weight: bold; color: #5ba633;">
                                    事项
                                </th>
                                <th width="100" style="font-size: 15px; font-weight: bold; color: #5ba633;">
                                    操作
                                </th>
                            </tr>
                            @for (int i = 0; i < 10; i++)
                            {
                                var imodel = Model[i];
                                if (ViewBag.startTime.AddDays(8) > DateTime.Now)
                                {
                                <tr class="listcontent tableline">
                                    <td align="center" class="mytd">
                                        <input type="text" class="input2" name="bp@(i)" id="bp@(i)" value="" />
                                        @Html.HiddenFor(model => model[i].uid, new { @id = "[" + i + "].uid" })
                                        @Html.HiddenFor(model => model[i].pid, new { @id = "[" + i + "].pid" })
                                    </td>
                                    <td>
                                        @Html.TextBoxFor(model => model[i].cost, new { size = 3, maxlength = 3 })
                                    </td>
                                    <td align="center">
                                        <div style="margin-top: 5px; margin-bottom: 5px;">
                                            @Html.TextAreaFor(model => model[i].title, new { @style = "width:95%;overflow:hidden;", rows = "5", cols = "70" })
                                        </div>
                                    </td>
                                    <td>
                                        @if (Model[i] != null && Model[i].pid != null && Model[i].cost != null)
                                        { 
                                            <button type="button" onclick="window.location.href='@Url.Action("Delete", new { startTime = ViewBag.startTime, endTime = ViewBag.endTime, uid = Model[i].uid })'"
                                    class="Button01" style="line-height: 24px; height: 24px; margin-top: 2px;">
                                                <span style="margin: 0px; padding: 0px;">清空</span>
                                            </button>
                                        }
                                    </td>
                                </tr>
                                }
                                else
                                {
                                    if (Model[i] != null)
                                    {
                                <tr class="listcontent tableline">
                                    <td>
                                        <span>[</span>@Html.DisplayFor(model => model[i].Project.code) <span>]</span> @Html.DisplayFor(model => model[i].Project.display)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => model[i].cost)
                                    </td>
                                    <td align="left">
                                        @Html.DisplayFor(model => model[i].title)
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                    }
                                }
                            }
                        </tbody>
                    </table>
                </div>
                @if (ViewBag.startTime.AddDays(8) > DateTime.Now)
                {
                    <div style="margin: 20px;">
                        <input class="Button01" style="line-height: 24px; height: 24px; margin-top: 2px;"
                            type="submit" value="提交" />
                    </div>
                }
            </div>
        </div>
    }
    @Html.CommonnScript()
    <script type="text/javascript">
        $(function () {
            $("input[name$='.cost']").blur(function () {
                var val = 0;
                $("input[name$='.cost']").each(function () {
                    if ($(this).val() != '') {
                        var val1 = parseInt($(this).val());
                        val = parseInt(val) + val1;
                    }
                });
                $('#SP01').text(val);
            });

              var data =  @ViewBag.ProjectJson;
            $("#tblList >tbody > tr > td > input[name^='bp']").each(function () {
                var txtId = $(this).attr("id").replace('bp', '');
                var hiddenId = document.getElementById("[" + txtId + "].pid");
                if (hiddenId.value != '') {
                    for (var j = 0; j < data.length; j++) { 
                        if (data[j].ID.toString().toLowerCase() == hiddenId.value.toLowerCase()) {

                            $(this).val(data[j].label);
                            break;
                        }

                    }

                }
                $(this).autocomplete("destory");
                $(this).autocomplete({
                    autoFocus: true,
                    delay: 0,
                    source: data,
                    minLength: 0,
                    select: function (event, ui) {

                        document.getElementById("[" + txtId + "].pid").value = ui.item.ID;
                        $("#bp" + txtId).val(ui.item.Name);

                    }
                }).click(function () { $(this).autocomplete("search", ""); });

            });
        });
    </script>
</body>
</html>
